from selenium import webdriver
from time import sleep
from PIL import Image
# from .api import main
from selenium.common.exceptions import NoSuchElementException
from .login import login_test
from .verification import main
import re
from selenium.webdriver.chrome.options import Options


def open_browser(browser_name, url):
    driver = None
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    chrome_options.add_argument('--window-size=1920,1080')
    if browser_name == "chrome":
        driver = webdriver.Chrome()
    if browser_name == "ff":
        driver = webdriver.Firefox()
    if browser_name == "ie":
        driver = webdriver.Ie()
    driver.maximize_window()
    driver.implicitly_wait(10)
    driver.get(url)
    return driver


class TestKeys(object):

    def __init__(self, browser_name, url, username, password, new_password):
        self.driver = open_browser(browser_name, url)
        self.username = username
        self.password = password
        self.new_password = new_password

    def webui1(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 系统管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]').click()
        # 用户一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]/ul/div/li[3]').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            if dicts["username2"] and dicts["user_role"] and dicts["user_email"] is not None:
                # 筛选条件-用户名称
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username2"])
                sleep(1)
                # 用户角色-选第一个
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                sleep(2)
                driver.find_element_by_xpath(('/html/body/div[2]//ul/li[%s]') % dicts["user_role"]).click()
                sleep(1)
                # 用户邮箱
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/input').send_keys(
                    dicts["user_email"])
                sleep(1)
                # 查询
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/div/span').text
                    print(error_text)
                returns_list.append(error_text)
                # 重置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
                sleep(2)
                continue
            if dicts["username2"] is not None:
                # 筛选条件-用户名称
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username2"])
                sleep(1)
                # 查询
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/div/span').text
                    print(error_text)
                # 重置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
                sleep(2)
                returns_list.append(error_text)
                driver.refresh()
                sleep(3)
                continue
            if dicts["user_role"] is not None:
                # 用户角色-选第一个
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                sleep(2)
                driver.find_element_by_xpath(('/html/body/div[2]//ul/li[%s]') % dicts["user_role"]).click()
                sleep(1)
                # 查询
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/div/span').text
                    print(error_text)
                # 重置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
                sleep(2)
                returns_list.append(error_text)
                driver.refresh()
                sleep(3)
                continue
            if dicts["user_email"] is not None:
                # 用户邮箱
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/input').send_keys(dicts["user_email"])
                sleep(1)
                # 查询
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/div/span').text
                    print(error_text)
                # 重置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
                sleep(2)
                returns_list.append(error_text)
                driver.refresh()
                sleep(3)
                continue
        print(returns_list)
        return returns_list

    def webui2(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 系统管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]').click()
        # 用户一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]/ul/div/li[3]').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            # driver.refresh()
            # 新增用户
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/header/div[2]/button[1]').click()
            sleep(1)
            if dicts["username2"] is not None:
                # 用户名称
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username2"])
                sleep(1)
            # 性别 固定男
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[2]/div/div/label[1]/span[1]').click()
            sleep(1)
            if dicts["staff_role"] is not None:
                # 员工角色选第一个
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[1]/div/div/div/div[2]/span/span').click()
                sleep(2)
                if dicts["username2"] is None:
                    driver.find_element_by_xpath('/html/body/div[6]//ul/li[2]').click()
                    sleep(1)
                else:
                    driver.find_element_by_xpath('/html/body/div[3]/div[1]/div[1]/ul/li[2]').click()
                    sleep(1)
            if dicts["staff_name"] is not None:
                # 员工姓名
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[1]/input').click()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[1]/input').send_keys(dicts["staff_name"])
                sleep(1)
            if dicts["job_number"] is not None:
                # 员工工号
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[1]/div/div/div/input').send_keys(dicts["job_number"])
                sleep(1)
            if dicts["phone"] is not None:
                # 联系电话
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[2]/div/div/div/input').send_keys(dicts["phone"])
                sleep(1)
            if dicts["email"] is not None:
                # 电子邮箱
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[1]/div/div/div[1]/input').send_keys(dicts["email"])
                sleep(1)
            # 所属部门-ROOT
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[2]/div/div/div/div/div[1]/span/span').click()
            sleep(2)
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[2]/div/div/div/div/div[2]/div[1]/div[1]/ul/div/div[1]/div[1]').click()
            sleep(1)
            if dicts["immediate_superior"] is not None:
                # 直属领导
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[1]/div/div/div/input').send_keys(dicts["immediate_superior"])
                sleep(1)
            if dicts["password"] is not None:
                # 密码设置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/div[1]/input').send_keys(dicts["password"])
                sleep(1)
            # 密码有效期
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[6]/div/div/div/div/input').click()
            # sleep(2)
            # 下个月
            # driver.find_element_by_xpath('/html/body/div[7]/div[1]/div/div[2]/button[3]').click()
            # sleep(2)
            # 确定
            # if dicts["staff_role"] is None:
            #     print(dicts["staff_role"])
            #     sleep(1)
            #     driver.find_element_by_xpath('/html/body/div[6]/div[2]/button[1]').click()
            # else:
            #     driver.find_element_by_xpath('/html/body/div[7]/div[2]/button[1]').click()
            # sleep(2)
            # 保存
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/div/button[2]').click()
            sleep(2)
            if dicts["username2"] == dicts["username_2"]:
                alert_text = driver.find_element_by_xpath('/html/body/div[4]/p').text
                print(alert_text)
                returns_list.append(alert_text)
                sleep(10)
                driver.refresh()
                continue
            if dicts["username2"] is None:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if dicts["staff_role"] is None:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if dicts["staff_name"] is None:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if dicts["email"] is None:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if dicts["password"] is None:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["username2"]) > 32:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["staff_name"]) > 32:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["job_number"]) > 50:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["phone"]) > 11:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["immediate_superior"]) > 32:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["password"]) < 8:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if len(dicts["password"]) > 32:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            if dicts["password"].isdigit():
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            regular = re.compile(r'[0-9a-zA-Z.]+@[0-9a-zA-Z-.]+?com')
            if not re.findall(regular, dicts["email"]):
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[1]/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                continue
            sleep(2)
            # 用户名称
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username2"])
            sleep(2)
            # 查询
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
            sleep(2)
            returns_list.append("新增成功")

        print(returns_list)
        return returns_list

    def webui3(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 系统管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]').click()
        # 用户一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]/ul/div/li[3]').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            # 用户名称
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username2"])
            sleep(1)
            # 用户角色
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/input').click()
            sleep(1)
            if dicts["user_role"] == "测试角色名称":
                driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[2]').click()
                sleep(1)
            # 用户邮箱
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/input').send_keys(dicts["user_email"])
            sleep(1)
            # 查询
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
            sleep(2)
            # 编辑
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/table/tbody/tr/td[9]/div/button[1]').click()
            sleep(1)
            if dicts["username_2"] is not None:
                # 用户名称
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[1]/div/div/div/input').clear()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username_2"])
                sleep(1)
            # 性别 固定女
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[1]/div[2]/div/div/label[2]/span[1]').click()
            sleep(1)
            if dicts["staff_role"] is not None:
                # 员工角色选第一个
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[1]/div/div/div/div[1]/span/span/i').click()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[1]/div/div/div/div[2]/span/span').click()
                sleep(2)
                if dicts["username_2"] is None:
                    driver.find_element_by_xpath('/html/body/div[6]//ul/li[1]').click()
                    sleep(1)
                else:
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[1]').click()
                    sleep(1)
            if dicts["staff_name"] is not None:
                # 员工姓名
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[1]/input').click()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[1]/input').clear()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[2]/div[2]/div/div/div[1]/input').send_keys(dicts["staff_name"])
                sleep(1)
            if dicts["job_number"] is not None:
                # 员工工号
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[1]/div/div/div/input').clear()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[1]/div/div/div/input').send_keys(dicts["job_number"])
                sleep(1)
            if dicts["phone"] is not None:
                # 联系电话
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[2]/div/div/div/input').clear()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[3]/div[2]/div/div/div/input').send_keys(dicts["phone"])
                sleep(1)
            if dicts["email"] is not None:
                # 电子邮箱
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[1]/div/div/div[1]/input').clear()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[1]/div/div/div[1]/input').send_keys(dicts["email"])
                sleep(1)
            # 所属部门-ROOT
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[2]/div/div/div/div/div[1]/input').click()
            sleep(2)
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[4]/div[2]/div/div/div/div/div[2]/div[1]/div[1]/ul/div/div[2]').click()
            sleep(1)
            if dicts["immediate_superior"] is not None:
                # 直属领导
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[1]/div/div/div/input').clear()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[1]/div/div/div/input').send_keys(dicts["immediate_superior"])
                sleep(1)
            if dicts["password"] is not None:
                # 密码设置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/button').click()
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/form/div[5]/div[2]/div/div/div/input').send_keys(dicts["password"])
                sleep(1)
            # 保存
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[3]/div/div[2]/div/div[1]/button[2]').click()
            sleep(1)
            # 重置
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
            sleep(2)
            # 用户名称
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username_2"])
            sleep(1)
            # 用户角色
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div[1]/input').click()
            sleep(2)
            driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[1]').click()
            sleep(1)
            # 用户邮箱
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/input').send_keys(dicts["email"])
            sleep(1)
            # 查询
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
            sleep(2)
            error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/footer/div/div/slot/span').text
            print(error_text)
            if error_text == "共 1 条":
                returns_list.append("编辑成功")
            else:
                returns_list.append("编辑失败")
            # 重置
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
            sleep(1)
            continue
        print(returns_list)
        return returns_list

    def webui4(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 系统管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]').click()
        # 用户一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[6]/ul/div/li[3]').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            # 用户名称
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["username_2"])
            sleep(1)
            # 用户角色
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/input').click()
            sleep(1)
            driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[1]').click()
            sleep(1)
            # 用户邮箱
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/input').send_keys(dicts["email"])
            sleep(1)
            # 查询
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
            sleep(2)
            # 删除
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/table/tbody/tr/td[9]/div/button[2]').click()
            # 确定
            driver.find_element_by_xpath('/html/body/div[7]/div/div[3]/button[2]').click()
            sleep(2)
            # 重置
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[2]').click()
            sleep(2)
            # 用户名称
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(
                dicts["username_2"])
            sleep(1)
            # 用户角色
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/input').click()
            sleep(1)
            driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[1]').click()
            sleep(1)
            # 用户邮箱
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/input').send_keys(
                dicts["email"])
            sleep(1)
            # 查询
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div/button[1]').click()
            sleep(2)
            error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/div[2]/div/main/div/div[3]/div/span').text
            print(error_text)
            if error_text == "暂无数据":
                returns_list.append("删除成功")
            else:
                returns_list.append("删除失败")
                continue
        print(returns_list)
        return returns_list

    def quit(self):
        """
        浏览器退出
        :return:
        """
        self.driver.quit()